/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) Microsoft Open Technologies, Inc.

http://www.cocos2d-x.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

#ifndef GAMEDIMENSIONS_H
#define GAMEDIMENSIONS_H

///@brief Some dimension data used in game ui
class GameDimensions
{
    public:
        ///@brief Constructor. generate and re-calculate all dimensions
        GameDimensions(int winWidth,int winHeight) {
            ratio=1;
            //if(winWidth<480 && winHeight<800){
                float r=1.0*winWidth/winHeight;
                float r0=480.0/800;
                if(r>r0){
                    //the width is too large
                    ratio=winHeight/800.0;
                }else{
                    //the height is too large
                    ratio=winWidth/480.0;
                }
            //
            width=(int)(ratio*480);
            height=(int)(ratio*800);
            //
            gwLeft=(winWidth-width)/2;
            gwTop=(winHeight-height)/2;

            gwCx=winWidth/2;
            gwCy=winHeight/2;

            //
            mainMenuHeight=(int)((800-160-100)*ratio/5);
            mainMenuX=gwLeft+width/2;
            mainMenuY=gwTop-(int)(height*0.2);

            //
            gameBoxBorder=width-6;
            gameBoxLeft=gwLeft+3;
            gameBoxTop =gwTop+height-(int)(220*ratio)-3;

            gameLabelW=(int)(300*ratio);
            gameLabelStepCx=gwLeft+(int)((480-150)*ratio);
            gameLabelBackCx=gameLabelTimeCx=gameLabelStepCx;
            gameLabelBackCy=gwTop+height-(int)(30*ratio);
            int hl=(int)(60*ratio);
            gameLabelStepCy=gameLabelBackCy-hl;
            gameLabelTimeCy=gameLabelStepCy-hl;

        }
        virtual ~GameDimensions() {}

        float ratio;

        //
        int width; ///<width of game window
        int height; ///<height of game window
        int gwLeft; ///<X coordinate of game window
        int gwTop; ///<Y coordinate of game window
        int gwCx;  ///<Ceneter X coordinate of game window
        int gwCy; ///<Center Y coordinate of game window

        ///dimensions of main menu
        int mainMenuHeight; ///<height of each menu in main menu scene
        int mainMenuX; ///<X coordinate of main menu
        int mainMenuY; ///<Y coordinate of main menu

        ///dimensions of game scene
        int gameBoxBorder; ///<border of the game touchable box
        int gameBoxLeft; ///<left coordinate of the game touchable box
        int gameBoxTop; ///<top coordinate of the game touchable box
        int gameStepLeft; ///<
        int gameStepTop;  ///<
        int gameTimeLeft; ///<
        int gameTimeTop;  ///<
        int gameInfoWidth; ///<
        int gameInfoHeight; ///<

        int gameLabelW;
        int gameLabelStepCx;
        int gameLabelStepCy;
        int gameLabelTimeCx;
        int gameLabelTimeCy;
        int gameLabelBackCx;
        int gameLabelBackCy;

        const static int PicCount=6; ///<picture count of game background
        const static int PicSrcBorder=480; ///<picture border size.


    protected:
    private:
};


#endif // GAMEDIMENSIONS_H
